What is a Shortcode

Molongui » Help » » What is a Shortcode

If you’ve been using WordPress for a little bit, you might have come across the term “shortcode”. While shortcodes are an exceptionally helpful feature in WordPress, the name isn’t very self-explanatory (at least at first). That might have you wondering… What is a shortcode in WordPress?

In a nutshell, a shortcode is a small piece of code that allow you to do various things with little effort.

They allow you to execute code inside WordPress posts, pages, and widgets without writing any code directly. This allows you to add a specific feature to your content. For example, a shortcode for displaying an author box by the Molongui Authorship plugin might look like this:

[author_box]

They can also come with attributes. For example, the author box shortcode mentioned above can take a show_avatar attribute:

[author_box show_avatar=no]

So, shortcodes simplify the addition of features to your WordPress site. Galleries, videos, and various other functionality would require a lot of code editing. By using shortcodes the HTML and other markup is added dynamically directly into the post or page where the user wants them to appear.

Shortcodes can be simply copied and pasted directly onto your site. Generally, they’re placed into a post or page. However, they can go in any location where you can add code through the WordPress editor, such as a custom post type or a text widget.

WordPress comes with several that are built in. These include audio, caption, embed, gallery, and video. Others are added by plugins. Molongui plugins provide several shortcodes for your convenience. Make sure to check out the plugin documentation to get to know how to use them.

Is There Anything Bad About Using Shortcodes?

Nope! There’s nothing wrong with using shortcodes. There is one thing you should remember, though: If you use shortcodes that come bundled with a plugin, those shortcodes will stop working if you ever disable that plugin.

This isn’t a “bad” thing – it’s just something you should be aware of so that you don’t get surprised down the road!

Hiding Unused Shortcodes

If you are using a plugin that utilizes shortcodes and you delete and or remove that plugin, your site could look really weird until you replace them. If you want to temporarily disable the shortcodes from the old plugin, simply use the following code in your functions.php file; updating plugin_shortcode_tag with the plugin’s actual shortcode tag.

				
					add_shortcode( 'plugin_shortcode_tag', '__return_false' );
				
			

This will disable them from showing altogether. But remember, if you want to use them with the original plugin again, you would need to remove the code. However, it can be a quick way to clean up your site while you replace the shortcodes with perhaps a newer plugin’s shortcode format.

Updated on January 22, 2022

Did not find a solution? We are here to help you succeed.
Open a support ticket